/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By 深圳中科鑫智科技有限公司
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.business.controller.kuaidi100.bsamecity;


import com.shop.cereshop.business.service.bsamecity.BsamecityOrderService;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.kuaidi.kd100.order.KdBsamecityOrderReq;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;


/**
 * <p>
 * 前端控制器
 * 同城寄件订单表
 * </p>
 *
 * @author
 * @date 2025-08-11
 */
@Slf4j
@RestController
@RequestMapping("/bsamecityOrder")
@Api(value = "BsamecityOrder", tags = "同城寄件订单表")
public class BsamecityOrderController {

    @Resource
    private BsamecityOrderService bsamecityOrderService;

    /**
     * 查询同城配送运费
     */
    @PostMapping("/bsamecityPrice")
    @ApiOperation(value = "查询同城配送运费", notes = "查询同城配送运费")
    public Result bsamecityPrice(@RequestBody KdBsamecityOrderReq bsamecityOrderReq, HttpServletRequest request) {
        CereBuyerUser user = (CereBuyerUser) request.getAttribute("user");
        if (user == null) {
            return new Result(CoReturnFormat.USER_NOT_LOGIN);
        }
        if (!Objects.equals(user.getBuyerUserId(), bsamecityOrderReq.getBuyerUserId())) {
            return new Result(CoReturnFormat.USER_NOT_LOGIN);
        }
        return bsamecityOrderService.bsamecityPrice(bsamecityOrderReq);
    }
}
